package com.focusai.efairy.ui.adapter.warn;

import android.support.v4.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.focusai.efairy.R;

import java.util.List;

/**
 * 选择商品中选仓库的适配器
 *
 * @author Ives
 */
public class SelectPaireAdapter extends BaseAdapter {
    private List<Pair<Integer, String>> locationList;

    public SelectPaireAdapter(List<Pair<Integer, String>> locationList) {
        this.locationList = locationList;
    }

    @Override
    public int getCount() {
        return this.locationList.size();
    }

    @Override
    public Pair<Integer, String> getItem(int position) {
        return this.locationList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView textName;
        if (convertView != null) {
            textName = (TextView) convertView.getTag();
        } else {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_center_text, parent, false);
            textName = (TextView) convertView.findViewById(R.id.text_center);
            convertView.setTag(textName);
        }
        textName.setText(locationList.get(position).second);
        return convertView;
    }

}
